<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../lib/vue.js"></script>
    <script src="../lib/vue-router.js"></script>
</head>

<body>
    <div id="app">
        <com1 v-bind:parentsmsg="msg" @func="getMsgFromSon"></com1>
    </div>
    <template id="tmpl">
        <div>
            <h3>这是子组件---{{parentsmsg}}</h3>
            <input type="button" value="想父组件传递消息" @click="sendMsg"/>
        </div>

    </template>
    <script>
        var com1 = {
            template: '#tmpl',
            data() {
                return {
                    msg: '做一个孝顺的孩子，给爸爸一些钱去挥霍吧！',
                    msgFromSon: ''
                }
            },
            props: ["parentsmsg"],
            methods: {
                sendMsg() {
                    this.$emit('func', this.msg)
                }
            }
        }
        var vm = new Vue({
            el: "#app",
            data: {
                msg: '这是父组件中的数据，爸爸有100块钱，my son，你要不'
            },
            components: {
                com1
            },
            methods: {
                getMsgFromSon(data) {
                    this.msgFromSon = data;
                    console.log(this.msgFromSon)
                }

            }

        })
    </script>

</body>

</html>